<!--
 * @Author: zhayang
 * @LastEditors: zhayang 1063975710@qq.com
 * @Date: 2024-06-18 23:17:15
 * @LastEditTime: 2024-06-19 22:51:58
 * @Description: 步骤条
-->
<template>
  <div class="steps-area flex flex-nowrap full-w">
    <div
      v-for="(item, index) in options"
      :key="item.id"
      class="step-item flex items-center"
      :class="[
        index === options.length - 1 ? 'col-auto' : 'col',
        disabled ? 'cursor-default' : 'cursor-pointer'
      ]"
      @click="!disabled && changeActive(index)"
    >
      <div
        class="step-item-logo h-24 w-24 rd-9999 text-14 center"
        :class="[
          active > index
            ? 'finish-item'
            : active === index
            ? 'active-item'
            : 'un-do-item'
        ]"
      >
        <span
          v-if="active > index"
          class="iconfont icon-duihao"
        ></span>
        <span v-else>
          {{ index + 1 }}
        </span>
      </div>
      <div
        class="m-l-8 text-14"
        :class="[
          active > index
            ? 'c-#1C1F23'
            : active === index
            ? '#04d1b8'
            : '#9e9e9e'
        ]"
      >
        {{ item.title }}
      </div>
      <div
        class="h-3 m-x-6 col"
        :class="[active === index ? 'bg-#04d1b8' : 'bg-#f4f5f9']"
      ></div>
    </div>
  </div>
</template>

<script>
export default {
  components: {},
  model: {
    prop: 'value',
    event: 'change'
  },
  props: {
    options: {
      type: Array,
      default: () => {
        return []
      }
    },
    value: {
      type: Number,
      default: 0
    },
    // 是否禁止点击切换状态
    disabled: Boolean
  },
  data() {
    return {
      active: 0
    }
  },
  watch: {
    value: {
      handler(newValue) {
        this.active = newValue
      },
      immediate: true
    }
  },
  created() {},
  methods: {
    changeActive(index) {
      this.active = index
      this.$emit('change', this.active)
    }
  }
}
</script>
<style lang="scss" scoped>
.step-item {
  position: relative;
}
.finish-item {
  background: transparent;
  color: #04d1b8;
  border: 1px solid #04d1b8;
}
.active-item {
  color: #fff;
  background: #04d1b8;
}
.un-do-item {
  background: transparent;
  border: 1px solid #9e9e9e;
  color: #9e9e9e;
}
</style>
